\(\int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx\) [24]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 76 \[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {1}{2} \left (a^2-3 b^2\right ) x-\frac {2 a b \log (\cos (c+d x))}{d}+\frac {3 b^2 \tan (c+d x)}{2 d}-\frac {\cos (c+d x) \sin (c+d x) (a+b \tan (c+d x))^2}{2 d} \]

[Out]

1/2*(a^2-3*b^2)*x-2*a*b*ln(cos(d*x+c))/d+3/2*b^2*tan(d*x+c)/d-1/2*cos(d*x+c)*sin(d*x+c)*(a+b*tan(d*x+c))^2/d

Rubi [A] (verified)

Time = 0.13 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3597, 1659, 788, 649, 209, 266} \[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {1}{2} x \left (a^2-3 b^2\right )-\frac {2 a b \log (\cos (c+d x))}{d}-\frac {\sin (c+d x) \cos (c+d x) (a+b \tan (c+d x))^2}{2 d}+\frac {3 b^2 \tan (c+d x)}{2 d} \]

[In]

Int[Sin[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

((a^2 - 3*b^2)*x)/2 - (2*a*b*Log[Cos[c + d*x]])/d + (3*b^2*Tan[c + d*x])/(2*d) - (Cos[c + d*x]*Sin[c + d*x]*(a
 + b*Tan[c + d*x])^2)/(2*d)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 266

Int[(x_)^(m_.)/((a_) + (b_.)*(x_)^(n_)), x_Symbol] :> Simp[Log[RemoveContent[a + b*x^n, x]]/(b*n), x] /; FreeQ
[{a, b, m, n}, x] && EqQ[m, n - 1]

Rule 649

Int[((d_) + (e_.)*(x_))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Dist[d, Int[1/(a + c*x^2), x], x] + Dist[e, Int[x/
(a + c*x^2), x], x] /; FreeQ[{a, c, d, e}, x] &&  !NiceSqrtQ[(-a)*c]

Rule 788

Int[(((d_.) + (e_.)*(x_))*((f_) + (g_.)*(x_)))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Simp[e*g*(x/c), x] + Dist[1
/c, Int[(c*d*f - a*e*g + c*(e*f + d*g)*x)/(a + c*x^2), x], x] /; FreeQ[{a, c, d, e, f, g}, x]

Rule 1659

Int[(Pq_)*((d_) + (e_.)*(x_))^(m_.)*((a_) + (c_.)*(x_)^2)^(p_), x_Symbol] :> With[{Q = PolynomialQuotient[Pq,
a + c*x^2, x], f = Coeff[PolynomialRemainder[Pq, a + c*x^2, x], x, 0], g = Coeff[PolynomialRemainder[Pq, a + c
*x^2, x], x, 1]}, Simp[(d + e*x)^m*(a + c*x^2)^(p + 1)*((a*g - c*f*x)/(2*a*c*(p + 1))), x] + Dist[1/(2*a*c*(p
+ 1)), Int[(d + e*x)^(m - 1)*(a + c*x^2)^(p + 1)*ExpandToSum[2*a*c*(p + 1)*(d + e*x)*Q - a*e*g*m + c*d*f*(2*p
+ 3) + c*e*f*(m + 2*p + 3)*x, x], x], x]] /; FreeQ[{a, c, d, e}, x] && PolyQ[Pq, x] && NeQ[c*d^2 + a*e^2, 0] &
& LtQ[p, -1] && GtQ[m, 0] &&  !(IGtQ[m, 0] && RationalQ[a, c, d, e] && (IntegerQ[p] || ILtQ[p + 1/2, 0]))

Rule 3597

Int[sin[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[b/f, Subst[Int
[x^m*((a + x)^n/(b^2 + x^2)^(m/2 + 1)), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && IntegerQ[m/
2]

Rubi steps \begin{align*} \text {integral}& = \frac {b \text {Subst}\left (\int \frac {x^2 (a+x)^2}{\left (b^2+x^2\right )^2} \, dx,x,b \tan (c+d x)\right )}{d} \\ & = -\frac {\cos (c+d x) \sin (c+d x) (a+b \tan (c+d x))^2}{2 d}-\frac {\text {Subst}\left (\int \frac {(a+x) \left (-a b^2-3 b^2 x\right )}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{2 b d} \\ & = \frac {3 b^2 \tan (c+d x)}{2 d}-\frac {\cos (c+d x) \sin (c+d x) (a+b \tan (c+d x))^2}{2 d}-\frac {\text {Subst}\left (\int \frac {-a^2 b^2+3 b^4-4 a b^2 x}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{2 b d} \\ & = \frac {3 b^2 \tan (c+d x)}{2 d}-\frac {\cos (c+d x) \sin (c+d x) (a+b \tan (c+d x))^2}{2 d}+\frac {(2 a b) \text {Subst}\left (\int \frac {x}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{d}+\frac {\left (b \left (a^2-3 b^2\right )\right ) \text {Subst}\left (\int \frac {1}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{2 d} \\ & = \frac {1}{2} \left (a^2-3 b^2\right ) x-\frac {2 a b \log (\cos (c+d x))}{d}+\frac {3 b^2 \tan (c+d x)}{2 d}-\frac {\cos (c+d x) \sin (c+d x) (a+b \tan (c+d x))^2}{2 d} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(162\) vs. \(2(76)=152\).

Time = 2.70 (sec) , antiderivative size = 162, normalized size of antiderivative = 2.13 \[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {b \left (\frac {\left (-a^2+b^2\right ) \arctan (\tan (c+d x))}{b}+2 a \cos ^2(c+d x)+\left (2 a+\frac {a^2-2 b^2}{\sqrt {-b^2}}\right ) \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )+\left (2 a+\frac {-a^2+2 b^2}{\sqrt {-b^2}}\right ) \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )+\frac {\left (-a^2+b^2\right ) \sin (2 (c+d x))}{2 b}+2 b \tan (c+d x)\right )}{2 d} \]

[In]

Integrate[Sin[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

(b*(((-a^2 + b^2)*ArcTan[Tan[c + d*x]])/b + 2*a*Cos[c + d*x]^2 + (2*a + (a^2 - 2*b^2)/Sqrt[-b^2])*Log[Sqrt[-b^
2] - b*Tan[c + d*x]] + (2*a + (-a^2 + 2*b^2)/Sqrt[-b^2])*Log[Sqrt[-b^2] + b*Tan[c + d*x]] + ((-a^2 + b^2)*Sin[
2*(c + d*x)])/(2*b) + 2*b*Tan[c + d*x]))/(2*d)

Maple [A] (verified)

Time = 1.17 (sec) , antiderivative size = 109, normalized size of antiderivative = 1.43

method result size
derivativedivides \(\frac {a^{2} \left (-\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )+2 a b \left (-\frac {\left (\sin ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\cos \left (d x +c \right )\right )\right )+b^{2} \left (\frac {\sin ^{5}\left (d x +c \right )}{\cos \left (d x +c \right )}+\left (\sin ^{3}\left (d x +c \right )+\frac {3 \sin \left (d x +c \right )}{2}\right ) \cos \left (d x +c \right )-\frac {3 d x}{2}-\frac {3 c}{2}\right )}{d}\) \(109\)
default \(\frac {a^{2} \left (-\frac {\sin \left (d x +c \right ) \cos \left (d x +c \right )}{2}+\frac {d x}{2}+\frac {c}{2}\right )+2 a b \left (-\frac {\left (\sin ^{2}\left (d x +c \right )\right )}{2}-\ln \left (\cos \left (d x +c \right )\right )\right )+b^{2} \left (\frac {\sin ^{5}\left (d x +c \right )}{\cos \left (d x +c \right )}+\left (\sin ^{3}\left (d x +c \right )+\frac {3 \sin \left (d x +c \right )}{2}\right ) \cos \left (d x +c \right )-\frac {3 d x}{2}-\frac {3 c}{2}\right )}{d}\) \(109\)
risch \(2 i a b x +\frac {a^{2} x}{2}-\frac {3 b^{2} x}{2}+\frac {{\mathrm e}^{2 i \left (d x +c \right )} a b}{4 d}+\frac {i {\mathrm e}^{2 i \left (d x +c \right )} a^{2}}{8 d}-\frac {i {\mathrm e}^{2 i \left (d x +c \right )} b^{2}}{8 d}+\frac {{\mathrm e}^{-2 i \left (d x +c \right )} a b}{4 d}-\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} a^{2}}{8 d}+\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} b^{2}}{8 d}+\frac {4 i a b c}{d}+\frac {2 i b^{2}}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}-\frac {2 a b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(174\)

[In]

int(sin(d*x+c)^2*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(a^2*(-1/2*sin(d*x+c)*cos(d*x+c)+1/2*d*x+1/2*c)+2*a*b*(-1/2*sin(d*x+c)^2-ln(cos(d*x+c)))+b^2*(sin(d*x+c)^5
/cos(d*x+c)+(sin(d*x+c)^3+3/2*sin(d*x+c))*cos(d*x+c)-3/2*d*x-3/2*c))

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 101, normalized size of antiderivative = 1.33 \[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {2 \, a b \cos \left (d x + c\right )^{3} - 4 \, a b \cos \left (d x + c\right ) \log \left (-\cos \left (d x + c\right )\right ) + {\left ({\left (a^{2} - 3 \, b^{2}\right )} d x - a b\right )} \cos \left (d x + c\right ) - {\left ({\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, b^{2}\right )} \sin \left (d x + c\right )}{2 \, d \cos \left (d x + c\right )} \]

[In]

integrate(sin(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/2*(2*a*b*cos(d*x + c)^3 - 4*a*b*cos(d*x + c)*log(-cos(d*x + c)) + ((a^2 - 3*b^2)*d*x - a*b)*cos(d*x + c) - (
(a^2 - b^2)*cos(d*x + c)^2 - 2*b^2)*sin(d*x + c))/(d*cos(d*x + c))

Sympy [F]

\[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \sin ^{2}{\left (c + d x \right )}\, dx \]

[In]

integrate(sin(d*x+c)**2*(a+b*tan(d*x+c))**2,x)

[Out]

Integral((a + b*tan(c + d*x))**2*sin(c + d*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 82, normalized size of antiderivative = 1.08 \[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {2 \, a b \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 2 \, b^{2} \tan \left (d x + c\right ) + {\left (a^{2} - 3 \, b^{2}\right )} {\left (d x + c\right )} + \frac {2 \, a b - {\left (a^{2} - b^{2}\right )} \tan \left (d x + c\right )}{\tan \left (d x + c\right )^{2} + 1}}{2 \, d} \]

[In]

integrate(sin(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/2*(2*a*b*log(tan(d*x + c)^2 + 1) + 2*b^2*tan(d*x + c) + (a^2 - 3*b^2)*(d*x + c) + (2*a*b - (a^2 - b^2)*tan(d
*x + c))/(tan(d*x + c)^2 + 1))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 981 vs. \(2 (70) = 140\).

Time = 0.62 (sec) , antiderivative size = 981, normalized size of antiderivative = 12.91 \[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\text {Too large to display} \]

[In]

integrate(sin(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/2*(a^2*d*x*tan(d*x)^3*tan(c)^3 - 3*b^2*d*x*tan(d*x)^3*tan(c)^3 - 2*a*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*
x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^3*tan(c)^3 + a^2*d*x*tan(d*x)^3*tan
(c) - 3*b^2*d*x*tan(d*x)^3*tan(c) - a^2*d*x*tan(d*x)^2*tan(c)^2 + 3*b^2*d*x*tan(d*x)^2*tan(c)^2 + a^2*d*x*tan(
d*x)*tan(c)^3 - 3*b^2*d*x*tan(d*x)*tan(c)^3 + a*b*tan(d*x)^3*tan(c)^3 - 2*a*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*t
an(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^3*tan(c) + 2*a*b*log(4*(tan(d*
x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^2*tan(c)^2
+ a^2*tan(d*x)^3*tan(c)^2 - 3*b^2*tan(d*x)^3*tan(c)^2 - 2*a*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) +
 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)*tan(c)^3 + a^2*tan(d*x)^2*tan(c)^3 - 3*b^2*tan
(d*x)^2*tan(c)^3 - a^2*d*x*tan(d*x)^2 + 3*b^2*d*x*tan(d*x)^2 + a^2*d*x*tan(d*x)*tan(c) - 3*b^2*d*x*tan(d*x)*ta
n(c) - a*b*tan(d*x)^3*tan(c) - a^2*d*x*tan(c)^2 + 3*b^2*d*x*tan(c)^2 - 5*a*b*tan(d*x)^2*tan(c)^2 - a*b*tan(d*x
)*tan(c)^3 + 2*a*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan
(c)^2 + 1))*tan(d*x)^2 - 2*b^2*tan(d*x)^3 - 2*a*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x
)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)*tan(c) - 2*a^2*tan(d*x)^2*tan(c) + 2*a*b*log(4*(tan(d*x)^2
*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(c)^2 - 2*a^2*tan(d*x
)*tan(c)^2 - 2*b^2*tan(c)^3 - a^2*d*x + 3*b^2*d*x + a*b*tan(d*x)^2 + 5*a*b*tan(d*x)*tan(c) + a*b*tan(c)^2 + 2*
a*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1)) + a
^2*tan(d*x) - 3*b^2*tan(d*x) + a^2*tan(c) - 3*b^2*tan(c) - a*b)/(d*tan(d*x)^3*tan(c)^3 + d*tan(d*x)^3*tan(c) -
 d*tan(d*x)^2*tan(c)^2 + d*tan(d*x)*tan(c)^3 - d*tan(d*x)^2 + d*tan(d*x)*tan(c) - d*tan(c)^2 - d)

Mupad [B] (verification not implemented)

Time = 4.62 (sec) , antiderivative size = 75, normalized size of antiderivative = 0.99 \[ \int \sin ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {{\cos \left (c+d\,x\right )}^2\,\left (a\,b-\mathrm {tan}\left (c+d\,x\right )\,\left (\frac {a^2}{2}-\frac {b^2}{2}\right )\right )+b^2\,\mathrm {tan}\left (c+d\,x\right )+a\,b\,\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )+d\,x\,\left (\frac {a^2}{2}-\frac {3\,b^2}{2}\right )}{d} \]

[In]

int(sin(c + d*x)^2*(a + b*tan(c + d*x))^2,x)

[Out]

(cos(c + d*x)^2*(a*b - tan(c + d*x)*(a^2/2 - b^2/2)) + b^2*tan(c + d*x) + a*b*log(tan(c + d*x)^2 + 1) + d*x*(a
^2/2 - (3*b^2)/2))/d